{{template "base/base.html" .}}
{{define "head"}}
<title>sss</title>
{{end}}
{{define "body"}}
<div class="testing">
    <header class="main">
        <h1><strong>Retina</strong> Dashboard</h1>
    </header>
    <section class="user">

        <div class="buttons">
            <span class="button blue"><a href="/admin/login_out/{{.tel}}">登出</a></span>
        </div>
    </section>
</div>
<nav>     <!--左侧导航部分-->
    <ul>
        <li><a href="/admin/index/{{.tel}}"><span class="icon">&#128711;</span> 设备监控</a></li>
        <li><a href="/admin/admin_list/{{.tel}}"><span class="icon">&#128101;</span>管理员</a></li>
        <li class="section">
            <a href="/admin/sys_setting/{{.tel}}"><span class="icon">&#9881;</span>系统设置</a>
        </li>
        <li>
            <a href="/admin/show_remote_list/{{.tel}}"><span class="icon">&#9881;</span>显示遥控数据</a>
        </li>
        <li>
            <a href="/admin/add_remote_data/{{.tel}}"><span class="icon">&#9881;</span>添加遥控数据</a>
        </li>
        <li>
            <a href="/admin/app_list/{{.tel}}"><span class="icon">&#9881;</span>app版本管理</a>
        </li>
    </ul>
</nav>

<section class="topcontent">
    <section class="widget">
        <header>
            <span class="icon">&#128100;</span>
            <hgroup>
                <h1>系统设置</h1>
            </hgroup>

        </header>
        <div class="syssetting_form_class">
            <div class="content">
                <div id="sys_seting">
                    <!-- <form id="register_form" >-->
                    <div class="txt-fld">
                        <label for="">时间粒度大小</label>
                        <input type="text" class="sys_txt" value={{.particleSize}} id="ParticleSize" />
                        <button id="ParticleSize_btn" class="sys_btn" type="submit">确定</button>
                    </div>
                    <div class="txt-fld">
                        <label for=""> 自动控制状态</label>
                        <!--<input type="text" class="sys_txt" value={{.mahine_learn}} id="IsMashineLearn" />-->
                        <select class="sys_select" id="sys_select">
                            <option value="true">开启</option>
                            <option value="false">关闭</option>
                        </select>
                        <button id="IsMashineLearn_btn" class="sys_btn" type="submit">确定</button>
                    </div>
                    <div class="txt-fld">
                        <label for="">触发阀值</label>
                        <input type="text" class="sys_txt" value={{.thresholdValue}} id="ThresholdValue" />
                        <button id="ThresholdValue_btn" class="sys_btn" type="submit">确定</button>
                    </div>
                    <!--</form>-->
                </div>
            </div>
        </div>
    </section>
</section>
<script type="text/javascript">
    $(document).ready(function() {
        var mahine_learn = {{.mahine_learn}};

    console.log(mahine_learn == false)
    $("#sys_select option").each(function(item){
        //console.log(($("#sys_select").get(0).options[item].value));
        //console.log(($("#sys_select").get(0).options[item].value) == mahine_learn.toString());

        if (($("#sys_select").get(0).options[item].value) == mahine_learn.toString()){
            //alert("s");
            $("#sys_select").get(0).options[item].selected = true;
        }
        //alert(item.val());//selected="selected"

    });
    $("#ParticleSize_btn").click(function(){
        data = {'ParticleSize':$('#ParticleSize').val()}
        $.post('http://'+window.location.host+'/admin/api/save_particle_size',data,function(data){
            //console.log(data)
            if(data.RespCode == 200){
                //alert("添加用户成功");
                window.location.reload()
            }else{
                alert(data.Msg);
            }

        });
    });
    $("#IsMashineLearn_btn").click(function(){
        data = {'SysMashineLearn':$('#sys_select').val()}
        //console.log($('#sys_select').val())
        $.post('http://'+window.location.host+'/admin/api/save_machine_learn',data,function(data){
            console.log(data)
            if(data.RespCode == 200){
                //alert("添加用户成功");
            }else{
                alert(data.Msg);
            }

        });
    });
    $("#ThresholdValue_btn").click(function(){
        alert($('#ThresholdValue').val())
        data = {'ThresholdValue':$('#ThresholdValue').val()}
        $.post('http://'+window.location.host+'/admin/api/save_threshold',data,function(data){
            console.log(data)
            if(data.RespCode == 200){
                //alert("添加用户成功");
            }else{
                alert(data.Msg);
            }

        });
    });

    });
</script>
{{end}}